package com.bjpowernode.boss.common.client;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.TimeUnit;

@Component
public class RedisClient {

    private StringRedisTemplate stringRedisTemplate;


    private HashOperations<String, Object, Object> hashOperations;

    public RedisClient(StringRedisTemplate stringRedisTemplate) {

        this.stringRedisTemplate = stringRedisTemplate;
        hashOperations = stringRedisTemplate.opsForHash();
    }

    public Boolean setHashMap(String Key, Map<String, String> data, int timeout, TimeUnit TimeUnit) {
        hashOperations.putAll(Key, data);
        return stringRedisTemplate.expire(Key, timeout, TimeUnit);
    }

}
